<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class test_class_product_class extends UnitTestCase{
	 function setUp(){
		 $this->_CI =& get_instance();
		 $this->_CI->load->library( 'product_class' );

		 $this->product_class_name = 'test' . time();
		 $this->_CI->db->trans_begin();
		 $this->_CI->db->trans_rollback();
	 }
	 function tearDown(){
		 //删除所有以 test 开头的文件夹
		 $this->_CI->load->helper( 'directory' );
		 $dirs = directory_map( APPPATH . 'views/mod/base_index_product_class_infos/' ); 
		 foreach( $dirs as $dir_name=>$v ){
			 if( preg_match( '/^test[1-9]*/' , $dir_name ) ){
				 $this->_CI->product_class->del( array( 'product_class_name'=>$this->product_class_name ) );
			 }
		 }
	 }
	 //添加新的服务
	 function test_create_new_product_class(){	 
		 $this->_CI->product_class->add_new( array( 'product_class_name'=>$this->product_class_name , 'product_class_name_cn'=>'测试' ) , '测试测试' );
	 }
}

$test = new test_class_product_class();
$test->run( new HtmlReporter() );

